2. generic device 2
因此,让我们开始在全局变量中为通用设备开发此功能块,您将看到所有活塞都有所有执行器和传感器。
So let's start to develop this function block for the generic device over here in the global variables, you will see that you have all the actuators and sensors for all the pistons.
正如你所看到的,它们是不同的,因为设备不同。
And as you can see there, they are different because the device, the devices are different.
在这里,我们有一些针对通用设备的反馈,稍后我们将在可视化中添加这些反馈。
And over here we are some feedback for the generic device that we will put later on on the visualization.
现在,我们不必担心这一点,因为我们想要开发功能性外观并开发功能块,这是开发功能块的好方法。
Right now, we don't have to worry about this because we want to develop a functional look and to develop a functional block, a good way to develop a function block.
它仅使用输入输出和内部变量,而不必依赖全局变量,因为功能块的目的是能够将其从一个项目移动到另一个项目以执行一项操作或任务。
It is about using only input output and internal variables without having to rely on global ones, because the purpose of the function block is to be able to move it from one project to another in order to perform an operation or a task.
现在,让我们通过单击右键并单击广告文件夹来在应用程序中创建一个文件夹。
So let's now create in our application a folder by clicking right clicking and clicking on ad folder.
我们将此文件夹称为通用设备。
And let's call this folder generic device.
在此文件夹中。
In this folder.
我们将把与通用设备开发相关的所有内容放在这里。
We will we put over here everything that is related to the generic device development.
我们在这里创建另一个文件夹,我将其称为数据类型,因为我们稍后将使用一些时间,并且将它们收集在专用文件夹中可能会很有用。
And we create another folder in here that I will call data types, since we will be using later on some a of times and it may be useful to collect them in a dedicated folder.
那么让我们开始吧,我们需要创建一个功能块。
So let's start and we will need to create a function block.
那么让我们在这里添加预览。
So let's go over here, add a preview.
类型将是功能块,实现语言将是文本结构。
The type will be a function block and the implementation language will be the structure of text.
我们将此 FBC 称为下划线通用设备。
And let's call this FBC underscore generic device.
因此,让我们开始编写函数工作的第一个,呃,初稿。
And so let's start to write the first, uh, first draft of our function work.
我们希望在这里链接这个按钮,这个启用的活塞按钮作为通用设备的输入。
We would want here to link this button, this enabled piston button as an input for the generic device.
因此,我们需要布尔变量,如果布尔变量等于 true,则意味着有人正在请求激活、启用设备。
So we would want boolean variable that if the Boolean variable is equal to true, it means that someone is requesting for the device to be activated, to be enabled to.
在活塞的情况下,你上升这个启用的活塞,把这个启用的活塞圣经通过它意味着请求活塞向前移动到启用反馈(如果它存在),否则强迫我移动活塞是愤世嫉俗的。活塞向后移动至负极限。
In the case of a piston, you rising this enabled piston, putting this enabled piston bible through it means to request for the piston to move forward to the enable feedback if it is present otherwise, and it would be cynical to force me to move the piston backward to its negative limit.
那么让我们转到这里,呃,首先输入我们将调用语音命令,这将是一个布尔变量。
So let's head over here, uh, first input that we will call the voice command and this will be a boolean variable.
让我们也写一下它的含义的评论。
And let's also write a comment on what it means.
这意味着如果该变量为通过,则意味着这是对设备的启用请求。
It means that if the variable is through, it means that this is an enabling request for the device.
如果它是假的,这意味着这些请求是可行的吗?
And if it is false, this means that is it is are these able requests?
好的,所以我们还需要区分设备的类型。
OK, so we would also need to distinguish the type of device.
正如我们在这里看到的,我们首先区分了两种类型的激活,即单激活或双激活,正如您所看到的,通过激活的数量、这里的执行器和四种类型的反馈,这样我们就可以得到无反馈、单个启用反馈、单个禁用反馈或双反馈。
So as we saw over here, we made the first distinction on the two types of activation, a single activation or a double activation, as you can see, by the number of activations, actuators over here and four types of feedback so we can have no feedback, a single enabled feedback, a single disable feedback or a double feedback.
因此,为了以编程方式获得实际的结构,让我们在这里创建一些数字,以便以精确的方式描述设备的这些类型的配置。
So in order to have an actual structure in the way of programming, let's create over here a few innumeracy in order to describe in a precise way these kinds of, uh, of configurations for the device.
那么让我们来看看服装吧。
So let's go into that attires.
右键单击,添加对象,让我们创建一个用户独特类型的任务。
Right, click, add object and let's create a duty that a user to unique type.
因此,让我们创建一个枚举,并调用此枚举反馈类型以便能够实现。
So let's create an enumeration and let's call this enum feedback type in order to be able.
您可以通过单击来区分我们通用设备的反馈类型,好吧,您会看到这是,呃,插入到我们的普通投影仪中,并且我们有两个不同的属性。
You distinguish that the type of feedback for our generic device by clicking, okay, you will see that this is, uh, is inserted in our normal projector and that we have two different attributes.
而且,你知道,这意味着什么?
And, you know, what does this mean?
我们已经看到了这一点,但只是合格的。
We already saw this, but the qualified only.
这意味着,为了,嗯,修改 Numerati 的值,你必须指定一个规范类型的 so 和 strict 值,意味着 strict 属性意味着你只能将这个 Numerati 设置为,呃,另一个和枚举属于同一类型。
It means that in order to, um, to modify the value of the Numerati, you have to specify that a normative type of so and strict value means the strict attribute means that you can only set this Numerati to, uh, to another and enumerated of the same type.
你不能,呃,将一个整数放入其中。
You cannot, uh, place an integer into this.
因此,就我们的目的而言,首先,我想保持严格,只删除合格的。
So for our purposes, first of all, I would like to maintain the strict one and remove the qualified only.
那么让我们看看我们的反馈类型是什么?
So let's see what are our types of feedbacks?
正如我们所说,我们没有任何反馈。
We have no feedback, as we said.
假设这等于零。
And let's say that this is equal to zero.
我们有一个启用的反馈。
We have a single enabled feedback.
假设这等于十。
Let's say that this is equal to ten.
我们的订单是这样的,然后我们有一个禁用反馈。
Our order this we have then a single disable feedback.
这等于二十。
This is equal to twenty.
最后一个是双重反馈。
And for the last one is the double feedback.
假设这等于 30。
And let's say that this is equal to 30.
因此,通过声明这种类型的功能块的输入,我们将能够将功能块配置为这四种反馈类型之一。
So by declaring an input for our function block of this type, we will be able to configure the function block as one of these four types of feedback.
因此,我们可以简单地转到设备的输入,然后创建另一个输入,我们将其称为反馈类型。
So we can simply go right over here on the input of the device and let's create another input that we will call feedback type.
那么这个输入,什么类型将是枚举反馈类型?
And this input, what type would be enum feedback type?
因此,使用这个,我们将能够将其配置为不同类型的反馈,并且以同样的方式,我们将为激活类型做同样的事情。
So using this one, we will be able to to configurator as different types of feedback and in the same way we will do the same, the same thing for the activation type.
那么让我们在这里声明一下其他的枚举。
So let's declare over here in other enumerated.
这么说吧,这是一种 noom 激活类型。
So let's say this, this is a noom activation type.
让我们在这里看看,没有任何驱动等于零。
Let's right over here, let's see, no actuation equal to zero.
这有点多余,但因为如果你有一个电工,你实际上没有设备,但让 Numerati 的零值实际上等于非值而不是空值实际上是一个很好的编程规则。
This is kind of redundant, but because if you have an electrician, you actually have no device, but it is actually a good programming rule to have the zero value of the Numerati actually equal to a non-value over an empty value.
因此,如果您指定该值,您实际上可以确定您的意思是这样,因为通常您可能会枚举默认值为零。
So if you specify the value, you're actually sure that you meant that because typically you may have an enumerated was default value is zero.
因此,如果您不希望以错误的方式配置任何内容,这是一个很好的方法。
So if you don't want anything to be configured in a wrong way, this is a nice way to do it.
让我们在这里删除限定的唯一属性并再次编写单个驱动。
Let's remove over here the qualified the only attribute and write also again, a single actuation.
假设这是数字 10,双驱动应该是数字 20。
Let's say that this is number 10 and double actuation should be number 20.
好的,继续,我们需要在此处添加另一个输入来指定驱动。
OK, so moving on, we will need to add another input over here to specify the actuation.
假设我们有一个驱动类型,数据类型是 Enuma 损耗类型。
So let's say that we have an actuation type and type of data is Enuma attrition type.
好的,现在让我们开始考虑设备的状态。
OK, so let's now start to think about the status of the device.
那么根据这个输入实际上应该发生什么?
So what actually should happen according to this input?
因此,我们也在这里创建一个设备、状态类型、一个设备、状态类型。
So let's also create over here a device, state type, a device, state type.
这是新的叙述。
And this is new narrative.
因此,假设我们有一个新的设备状态,我们可以再次删除限定的状态,在这里我们可以拥有不同的状态。
So let's say that we have a new device state and this again, we can remove the qualified only state and over here we can have different states.
我们将为我们的设备写入所有状态。
We will write all the states for our device.
因此,我们在这里写入零值,即设备未使用的关闭状态。
So let's write for the zero value over here, an off state where the device is not being used.
所以我们在这里说我们有一半,因为它等于零。
So we will say over here that we have half as that is equal to zero.
这意味着该设备未被使用。
That means the device is not being used.
这并不意味着该设备已被禁用。
This does not mean that the device is disabled.
因此,我们需要为设备禁用一个状态,在该状态下,从禁用到启用的转换(我们在这里称之为启用)以及设备启用时的状态。
So we will need to have a state for the device disabled in a state where there is a transition from disabled to enable the let's call this enabling over here and a state for when the device is the enabled.
我们称其等于 13。
Let's call this equal to 13.
再次,设备,从任何账单过渡到禁用的另一种状态。
And again, a device, the another state for the transition from any bill to disabled.
所以我们这里主要是编写一个状态机。
So what we have over here, mainly, we will write a state machine.
因此,这意味着禁用这四个状态之间的状态机。
So this was meant to be disabling a state machine between this four states.
所以我们稍后会处理所有这些关闭状态。
So we will handle all this off state later on.
但假设我们有一个实际上被禁用的设备。
But let's say that we have a device that is actually disabled.
我们需要将其移至设备正在启用并启用健康方面的请求的状态。
We will need to move it to in a state where the device is enabling upon and enable request from the health side.
然后设备将从启用状态转移到启用状态,如果,呃,如果实际上我们有设备实际启用的反馈,那么,再次,如果检测到来自外部的禁用请求。
Then the device will move from this state enabling to that and enable state if, uh, if actually we have a feedback that the device is actually enabled, then again, from an enabling state, we will need to move to a disabling state if a disabled request from the outside is detected.
然后,如果有请求,如果我们实际上有设备实际上已禁用的反馈,我们将需要从该状态转移到禁用状态。
And then we will need to move from this state to the disabled state if a request, if we have actually a feedback that the device is actually disabled.
因此,让我们转到我们的功能块,并在此处添加内部变量,以获得禁用或启用设备的实际内部反馈。
So let's go over here to our function block and let's also add over here to internal variables to have an actual internal feedback of the disabling or enabling of the device.
我们将在内部使用这些变量,因为根据反馈类型的反馈,它们将根据我们稍后将看到的输入具有不同的含义。
We will have that this these variables internally, because according to the feedback to the feedback type, they will have different meaning according to the inputs that we will see later on.
因此,让我们在这里和变量然后我们将调用内部可见的可见反馈。
So let's right over here and variable then we would call internal visible, visible feedback.
它是一个布尔变量和一个内部使能反馈。
It is a boolean variable and an internal enable feedback.
那是大胆的,行不通的。
That is a bold, unviable.
好的,让我们开始吧,我们还需要,呃,一个状态变量来实际跟踪状态,并且这些变量可以放置为设备的输出。
OK, so let's start to we also need, uh, a state variable to actually take track of the state and the these variables could be placed as an output of the device.
因此,我们将能够从外部看到它,并实际看到设备何时启用或未启用。
So we will be able to see it from outside and actually see when the device is enabled or not.
那么我们的变量正确吗?
So are we right at the variable?
这就是设备状态,类型实际上是枚举设备状态。
That is the device state and the type is actually enum device state.
因此,让我们真正开始编写通用设备状态机的草稿。
So let's actually start writing a draft of the generic device state machine.
所以在这里我会写一个注释来划分我们的代码。
So over here I will write a comment in order to divide our code.
让我们编写通用的设备状态机,这样我们就会有一个根据设备状态变量关闭和超过一年的情况,而不是编写通常的零、10、20、30等有价值的整数,我们可以直接编写变量的枚举值我们写的状态。
Let's write the generic device state machine so we will have a case according to the device state variable off and over a year, instead of writing the usual zero, 10, 20, 30 integer valuable, we can directly write the enumeration value of the variable of the state that we wrote.
因此,例如,我们将从禁用状态的禁用状态开始,并且我们需要留在这里,直到收到初始请求并且启用请求由该输入决定。
So we will start, for instance, from a disabled state in a disabled state, and we will need to stay here until we receive an initial request and enable request is dictated by this input.
因此,如果我们有一个设备到来并且平等通过,那么我们应该将状态更改为启用状态。
So we will have that if we have a device come and equality through, then we should change state to the enabling state.
所以在使能状态下该状态应该等于enable then。
So the state should be equal to enabling then in the enabling state.
如果我们处于启用状态,如果我们实际上收到设备已实际达到最终启用状态的反馈,我们将获得内部启用反馈,然后设备状态实际上应变为启用。
If we are in enabling state, if we receive actually the feedback that the device has actually reached the end enabled state, we will have our internal enable feedback then the device state it should actually become enabled.
好的。
OK.
然后转到启用状态,如果我们处于灵活状态,我们将不得不执行与此相反的操作。
Then moving to the enabled state, if we are in the nimble state, we will have to carry out the opposite operation of this.
因此,如果我们收到禁用的请求。
So if we receive a disabled request.
就在这里,一些评论。
So that's right over here, a few comments.
这是一个启用请求。
This is an enabling request.
这意味着国家将授权州法院授权。
It means that the state will become enabling state court to enabling.
而在这里,我们看到了相反的情况。
And over here, we have the opposite.
因此,如果我们收到合理的请求,我们将不得不进入禁用状态。
So if we receive a reasonable request, we will have to go to the disabling state.
因此,如果没有,买家到来,国家将不得不变得等于瘫痪。
So if not, the buyers come and the state will have to become equal to disabling.
好的,所以在这里,我们将拥有所需的状态,它将执行与这里的启用状态类似的操作抱歉,在这里和这里,如果内部可见反馈实际上现在等于 true,我们将不得不去至禁用状态。
OK, so over here, we will have the desired state that will carry out a similar operation to the enabling state over here sorry, over here and over here, if the internal visible feedback is actually now equal to true, we will have to go to the state disabled.
好的。
OK.
这是我们的状态机,是我们通用办公室的基本状态机转换。
This is our state machine, basic, really basic state machine transitions for our generic office.
我们实际上将添加一个新的。
We shall actually add a new one.
假设我们处于启用阶段,但实际上设备尚未启用。
So let's say that we are in the enabling phase over here and actually the device is not yet enabled.
假设在此阶段,我们实际上收到了禁用请求。
And let's say that during this phase, we actually receive a disable request.
所以我们失去了通常称为真实的设备。
So we lose the device commonly called the true.
如果这种情况确实发生,我们将不需要进入邻居的状态并返回到禁用状态。
If this actually happens, we will not need to go to the neighbor's state and go back to the disabling.
我们可以简单地跳过该状态并直接进入禁用状态。
We can simply skip the state and go directly to the disabling one.
所以就在这里。
So that's right over here.
另一个转换说,如果不是副卡拉蒙达,这意味着我们有一个禁用的请求,我们将需要进入设备状态,等于启用它,抱歉,等于禁用。
Another transition saying that if not the vice Kalamunda, meaning that we have a disabled request, we will need to go to the device state equal to enable it sorry, equal to disabling.
以同样的方式从禁用状态开始,如果我们再次收到启用命令,设备将跳过禁用状态并直接返回到启用状态。
And in the same way over here from the disabling state, if we receive a command to enable, again, the device which shall skip the disabled state and go directly back to the enabling one.
所以我们就在这里,如果不是设备命令的话。
So we're here, if not the device command.
因此,如果设备到来,则副状态将变为等于启用。
So if the device comes and then the vice state shall become equal to enabling.
好的,这是一种简单的状态机,它将执行我们实际需要的操作。
OK, so this is kind of simple state machine that will carry out what we actually need.
因此,我们实际上可以开始以虚拟方式测试它,通过手动强制这些值,以便更好地理解这一点。
So we may actually start testing it in, let's say, virtual way by forcing the values by hand in order to handle more understanding of this.
那么让我们进入我们的主程序。
So let's go into our main program.
我们也可以在 Object 处创建。
Let's also create over here at Object.
让我们创建一个操作,比如说 FDA,让它变得容易,呃,让我们将其称为通用设备调用,称为被调用调用。
Let's create an action, let's say an FDA, to have it easy for, uh, let's call this a generic device call called as called call.
让我们在主程序顾问中创建,假设我们将其简单地称为通用设备,并且该类型将是 F、B、下划线通用设备。
Let's create in the main program advisor, so let's say let's call it simply generic device, and this type will be F, B, underscore generic device.
让我们开始实施并调用该操作,然后将这个操作放在这里。
Let's move to the implementation and call the action and let's place in this action over here.
这是通用设备的第一个实现。
This first implementation of the generic device.
毒品,这里的一个盒子。
So a drug, a box from over here.
这将是我们的第一个通用设备。
And this will be our first generic device.
让我们删除它,以便我们能够编辑它们,让我们进入模拟,让我们上网看看它现在是如何工作的。
Let's remove this so we will be able to edit them and let's go into simulation and let's go online to see actually how this works for now.
现在,我们处于状态,我们没有处理这个,所以维护状态暂时保持关闭。
Right now, we are in the state, we did not handle this, so the state with maint stay off for now.
现在让我们看看。
So let's see that for now.
让我们通过进入设备并双击此处来集中双击。
Let's focus this double clicking by going into the device and double clicking on off over here.
现在让我们给残疾人看一下。
Let's watch this for now to the disabled.
所以我们实际上进入了我们的状态机。
So we are actually into our state machine.
假设我们收到并启用请求。
So let's say that we receive and enable request.
我们在这里强制设备通过。
We here forcing the device coming through.
实际上你可以看到我们的状态已经变得等于启用。
And actually you can see that our state has become equal to enabling.
所以我们正在等待能够提供反馈的互联网。
So we are waiting for the Internet that enables feedback.
如果我们收到内部启用反馈,则设备启用后座位数将变为 30。
If we get an internal enabled feedback, the seat will go to 30 with the device enabled.
如果然后我们真的通过将设备设置为Folsom来执行禁用请求,那么状态将变成您多年来也可以看到它,等于禁用。
If then we actually carry out a disable request by setting the device come to Folsom, the state will become you can see it over the years as well, equal to disabling.
在这里,我们正在等待可见的反馈,并通过强制它,我们回到这种禁用状态。
And over here we are waiting for the visible feedback and by forcing it, we get back to this disabled state.
这是我们国家机器的主圈,主要的,呃,世界圈。
This is the main circle, the main, uh, the world circle of our state machine.
我们还可以测试中间转换。
And we can also test the the intermediate transitions.
因此,如果我将设备命令设置为 through 并且在实际获得内部 Knebel 反馈之前,我会将其设置为 false。
So if I set a device command equal to through and before actually having an internal Knebel feedback, I set it to false.
我们回到禁用问题。
We get back to the disabling.
这是其工作原理的基础知识。
So this is the basics on how this is working.
因此,在这里,我将在状态机中添加另外一些内容,稍后您将清楚我这样做的原因。
So over here, I will add another few things in the state machine and later on you will have clear why I'm doing this.
所以一切的基础都是有意义的。
So the basics of everything is sensate.
我们需要,因为我们有不同类型的设备。
We need since we have different types of devices.
我们必须根据我们在非情况下拥有的设备类型将其映射到内部变量。
We will have to map this to internal variables according to the type of device that we have in the not case.
例如,我们实际上没有任何反馈,任何真实的反馈可以告诉我们状态是否实际上更改为启用或禁用与设备有关的内容。
For instance, we actually don't have any any feedback, any real feedback that tells us if the state is actually changed to enable or disabled for what concerns the device.
因此,为了正确处理设备,我们需要花费一些时间。
So in order to have correct the device handling, we will need to use some time or some.
例如,在这里,我们再次上网,只是为了模拟,在这里进行可视化,就一会儿。
For instance, over here, let's go online again just for the sake of simulation, going here to the visualization here, just for a moment.
抱歉,我必须关闭它。
Sorry, I have to close this.
抱歉,我会去在线设备可视化。
Sorry, I will go online devices visualization.
如果我们这里有这个活塞,我们就不会照顾。
If we have this piston over here, we will not take care of.
如果没有任何传感器,我们实际上无法真正知道设备是否已启用。
We cannot actually really know if the device is enabled or not without having any sensors.
所以我们将根据计时器承担财产。
So we will assume estate according to a timer.
所以我们会说,如果几秒钟后我们启用了设备,我们将假设该状态已以相同的方式达到 Anybots 状态。
So we will say that if after a few seconds that we have the device enabled, we will assume that this state has reached the Anybots state in the same way.
如果我们禁用它,我们实际上会看到它会在几秒钟后恢复。
If we disable it, we will actually see we will actually have it going back after a few seconds.
因此,我们将使用它并为设备启用时间或禁用时间。
So we will use it and enable time or disable time for the for the device.
那么我们就到这里吧。
So let's right over here.
让我们在这里添加一个计时器。
Let's add over here and a timer.
我们称其为内部定时器,类型应该是 atheel 类型。
Let's call this an internal timer and the type should be atheel one.
我们还可以编写另一个变量。
And let's also write another variable.
然后我们会在那里调用 time,告诉我们这个计时器何时到了,我们将在程序开始时调用这个计时器。
Then we will call time out there, will tell us when this timer as elapsed and we will call this timer at the beginning of our program.
那么让我们到这里,按 5 进行搜索,然后编写超时。
So let's go over here, press five to the search and let's write timeout.
非常抱歉。
So sorry.
抱歉,我不是不应该写超时吗,但是内部计时器和我们的超时输出将是超时将是内部计时器的输出。
Sorry, didn't I shouldn't have written timeout, but internal timer and our timeout output will be the timeout will be the output of the internal timer.
那么我们就写在这里吧。
So let's write this over here.
好的,为了做到这一点,我们将能够实际看到计时器的实际启动。
OK, so in order to do this, we shall be able to actually see actually start the timer.
当我们到达启用或禁用阶段时,我们还需要知道设备的实际激活或激活时间。
When we reach the enabling or disabling phase, we will also need to know an actual activation or the activation time for the device.
因此,我们将添加两个额外的输入,或者在这里我们将其称为设备激活时间。
So we will add the two additional inputs or here that we will call the device activation time.
这应该是一个时间变量,而设备,激活时间,应该有一个时间变量。
That should be a time of variable and the device, the activation time, there should be, again, a time variable.
因此,当我们到达启用阶段时,我们将根据激活时间启动计时器,所以我就在这里。
So when we reach the enabling phase, we shall start the timer with the activation time, so I will right over here.
在这里,我读到了内部计时器,这与事实相同。
Over here, I read internal timer that in equal to truth.
这是正确的。
That's right.
同样在这里,有一条评论说我们启动了计时器。
Also over here, a comment saying that we start the timer.
对于激活时间,正如我所说,我将编写等于通过的内部计时器和等于设备激活时间的内部计时器。
With the activation time, so as I said, I will write internal timer that in equal to through and internal timer that peaty equal to the device activation time.
同样,当我们达到禁用状态时,我将使用激活计时器启动计时器,因此我只需复制此内容并将其粘贴到此处。
In the same way, I shall start the timer with the activation timer when it's when we reach the disabling state, so I will just copy this and paste it over here.
让我们在评论和作业中将其从激活更改为停用。
Let's just change this to from activation to deactivations, both in the comment and in this assignment.
哦好的。
Oh, OK.
我还有另外几件事需要做,就是当我们达到禁用状态或启用状态时,我们需要实际重置计时器。
I have another few things that we need to do is when we reach a disabled state or an enabled state, we need to actually reset the timer.
为此我们可以简单地。
And for this we can simply.
这就是这里的一条评论,重置计时器,我们将通过设置同等力量的内部计时器来做到这一点。
That's right over here a comment, reset the timer and we shall do this by setting the internal timer that in equal force.
也许我们还可以覆盖内部计时器,将其设置为零秒,以便不必在之前的时间中出现在这里。
And maybe we can also override the internal timer that lets set it equal to zero seconds in order to not have to not have over here the previous time.
因此,当我们达到禁用状态以及此处达到启用状态时,我们应该禁用重置计时器。
So we should disable reset the timer when we reach the disabled state and also when we reach the enabled state over here.
好的,我们的状态机差不多完成了,我们需要注意的唯一一件事是,如果我们使其从启用状态到禁用状态的对角线转换,您可以看到设备计时器仍然保持运行状态。
OK, we are almost done with our state machine and the only other thing that we need to take care of is that if we make it the diagonal transition from the enabling state to the disabling state, you can see that the device timer remains through.
所以它永远不会被禁用。
So it is never disabled.
因此,我们需要做的是禁用它,至少对于一家 p.l.c.
So what we need to do is to disable it, at least for one p.l.c.
过渡期间的循环。
cycle during the transition.
因此,我们只需要做的就是再次在此转换中重置计时器,以便我们可以将计时器重新初始化为新时间。
So what we simply need to do is, again, reset the timer in this transition so we can reinitialize the timer to the new time.
所以我会再次复制这部分并将其放在此处并再次处于禁用状态。
So I will copy again this part and place it over here and again in the disabling state.
哦,对不起,对不起。
Oh, sorry, sorry.
本来不想在这里做这件事的。
Didn't mean to do this over here.
我打算在这里这样做,因为这是对角线过渡,在这里也是如此。
I meant to do this here because this is the diagonal transition and the same over here.
好的,根据逻辑,这应该工作得很好。
OK, so according to the logic, this should work quite fine.
而且,如果我们没有反馈设备,我们这次也会将其用作实际反馈。
And also we implement this time that we will use as the actual feedback if we have a no feedback device.
如果我们确实有反馈,我们也将使用它作为检测机制。
And we will also use this as a to detection mechanism if we have actually had feedback.
举例来说,假设我们正在启用该设备。
So, for instance, let's say let's say over here that we are enabling the device.
在这里,假设我们有一个反馈,让我们看看第二个,如果我在一段时间后启用活塞,我希望看到实际的反馈。
Over here, let's say that we have a feedback, let's look at the number two, if I enable the piston after a while, I expect to see the actual feedback going through.
如果它没有通过,这实际上可能会触发我们看到设备上存在一些故障,无论是在传感器上还是在激活上。
If it doesn't become through, this might actually be a trigger for us to see that there is some fault on the device, either on the sensor or on the activation.
我们稍后会看到这一点。
And we will see this later on.
无论如何,在设备中拥有这个计时器,当它从设备启用或禁用时转换时运行,对于我们的通用目的来说非常有用。
In any case, having this timer within the device that runs when it transition from when the device is either enabling or disabling is quite useful for us in a general purpose.
在接下来的几周内,我们将继续编写这个通用设备,我们实际上还将看到通用设备的跌倒诊断。
In the next few weeks, we will keep writing this generic device and we will see actually also the fall diagnosis of the the generic device.